How to use macros with the libreoffice conversion plugin
--------------------------------------------------------

1. It is necessary to use the LibreOffice plugin to make the conversion.

2. Open with a text editor the macros file.

This file is located in the home directory of the user that is going to make the conversion:
For example with the default configuration for the apache web server, it is located in the path /var/www/.config/libreoffice/V/user/basic/Standard/Module1.xba.
Or using FastCGI as PHP handler, this file is located at .config/libreoffice/{V}/user/basic/Standard/Module1.xba of ther user's folder in Linux. {V} is the LibreOffice version.
If the directory .config/libreoffice, doesn’t exists, make a first conversion so LibreOffice generates this path structure.
Using Windows, the default path of this file is in the AppData\Roaming\LibreOffice folder of the user's profile.

3. In the opened file, add the new macro. You may find the available macros in the macros folder.

4. You can now use the new macro.

These are the available options:

Generate TOC when transforming to PDF:

$docx->transformDocument('document.docx', 'document.pdf', 'libreoffice', array('toc' => true));

Generate PDF/A-1:

$docx->transformDocument('document.docx', 'document.pdf', 'libreoffice', array('pdfa1' => true));

Generate PDF/A-2:

$docx->transformDocument('document.docx', 'document.pdf', 'libreoffice', array('pdfa2' => true));

Generate PDF/A-3:

$docx->transformDocument('document.docx', 'document.pdf', 'libreoffice', array('pdfa3' => true));

Generate TOC when transforming to PDF/A-1:

$docx->transformDocument('document.docx', 'document.pdf', 'libreoffice', array('toc' => true, 'pdfa1' => true));

Generate TOC of a DOCX document (global path must be used as target folder):

$docx->transformDocument('document.docx', '/global_path/document.docx', 'libreoffice', array('toc' => true));

Export the notes/comments:

$docx->transformDocument('document.docx', 'document.docx', 'libreoffice', array('comments' => true));

Lossless compression:

$docx->transformDocument('document.docx', 'document.docx', 'libreoffice', array('lossless' => true));

Form fields:

$docx->transformDocument('document.docx', 'document.docx', 'libreoffice', array('formsfields' => true));

Get the document statistics:

$docx->getStatistics('document.docx');


How to add the comments in the margins
--------------------------------------------------------

1. Edit the configuration file properties of LibreOffice. This file is available in the HOME folder in the following path: .config/libreoffice/{V}/user/registrymodifications.xcu (Linux) or AppData\Roaming\LibreOffice folder of the user's profile (Windows).

2. Find the following line:

<item oor:path="/org.openoffice.Office.Writer/Print/Content"><prop oor:name="Note" oor:op="fuse"><value>0</value></prop></item>

And set '4' as value:

<item oor:path="/org.openoffice.Office.Writer/Print/Content"><prop oor:name="Note" oor:op="fuse"><value>4</value></prop></item>


Set lossless settings in LibreOffice configuration
--------------------------------------------------------

1. Edit the configuration file properties of LibreOffice. This file is available in the HOME folder in the following path: .config/libreoffice/{V}/user/registrymodifications.xcu (Linux) or AppData\Roaming\LibreOffice folder of the user's profile (Windows).

2. Find the following lines:

<item oor:path="/org.openoffice.Office.Common/Filter/PDF/Export"><prop oor:name="ReduceImageResolution" oor:op="fuse"><value>true</value></prop></item>

<item oor:path="/org.openoffice.Office.Common/Filter/PDF/Export"><prop oor:name="UseLosslessCompression" oor:op="fuse"><value>false</value></prop></item>

And replace them with:

<item oor:path="/org.openoffice.Office.Common/Filter/PDF/Export"><prop oor:name="ReduceImageResolution" oor:op="fuse"><value>false</value></prop></item>

<item oor:path="/org.openoffice.Office.Common/Filter/PDF/Export"><prop oor:name="UseLosslessCompression" oor:op="fuse"><value>true</value></prop></item>